package com.puff.ioc;

import com.puff.jdbc.tx.proxy.CglibProxy;
import com.puff.jdbc.tx.proxy.JDKProxy;
import com.puff.jdbc.tx.proxy.TXProxy;

public class TXProxyFactory {

	private static boolean cglibSupport = true;

	static {
		try {
			Class.forName("net.sf.cglib.proxy.MethodInterceptor");
		} catch (Exception e) {
			cglibSupport = false;
		}
	}

	public static TXProxy getProxy(Class<?> klass) {
		TXProxy proxy = null;
		try {
			proxy = new SourceProxy(klass);
		} catch (Throwable e) {
			if (cglibSupport) {
				proxy = new CglibProxy(klass);
			} else {
				proxy = new JDKProxy(klass);
			}
		}
		return proxy;
	}

}
